﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ProjectStudy.App_Code
{
    public class Trans
    {
        public static int ToInt(string s)
        {
            if (s != "" && s != null)
            {
                if (IsNum(s))
                {
                    return Convert.ToInt32(s);
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return 0;
            }
        }

        public static  bool IsNum(string str)
        {
            foreach (char ch in str)
            {
                if (ch < '0' || ch > '9')
                    return false;
            }
            return true;
        }

        public static string ToString(object s)
        {
            if (s == null)
            {
                return "";
            }
            else
            {
                return s.ToString();
            }
        }

    }

    
}